package com.xzzz.irda.guardcat.core.metric.memory;

import java.io.Serializable;

/**
 * 内存使用信息
 *
 * @author xzzz
 * @since 1.0.0
 */
public class MemoryUsageInfo extends BaseMemoryUsageInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 内存类型
     */
    private final String type;

    /**
     * 内存使用峰值
     * <p>
     * 自虚拟机启动或峰值重置以来，Java 虚拟机保持内存池的峰值内存使用。
     */
    private final UsageInfo peakUsageInfo;

    /**
     * GC 之后的内存使用情况
     */
    private final UsageInfo collectionUsageInfo;

    public MemoryUsageInfo(String name, UsageInfo usageInfo, String type, UsageInfo peakUsageInfo, UsageInfo collectionUsageInfo) {
        super(name, usageInfo);
        this.type = type;
        this.peakUsageInfo = peakUsageInfo;
        this.collectionUsageInfo = collectionUsageInfo;
    }

    @Override
    public String toString() {
        return "内存使用信息{" +
                "内存名称='" + getName() + '\'' +
                ", 内存类型='" + type + '\'' +
                ", 内存使用情况=" + getUsageInfo() +
                ", 内存使用峰值=" + peakUsageInfo +
                ", GC 之后的内存使用情况=" + collectionUsageInfo +
                '}';
    }
}
